﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using LongQuanWeb.App_Code;

namespace LongQuanWeb.Ventures
{
    public partial class ElegantList : System.Web.UI.Page
    {
        public string lbl_Description = "";
        public string lbl_browercount = "";
        public string prev = "";
        public string next = "";
        public string lbl_prev = "";
        public string lbl_next = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string id = Request.QueryString["id"].ToString().Trim();
                string strSql = "Select * From Activity Where AcitivityNum=" + id + "";
                DataTable dt = DbHelperSQL.Query(strSql).Tables[0];
                if (dt != null)
                {
                    //流量
                    int NewsBrowse = int.Parse(dt.Rows[0]["BrowerCount"].ToString().Trim()) + 1;
                    strSql = "Update [Activity] set BrowerCount=" + NewsBrowse + " where AcitivityNum=" + id + " ";
                    DbHelperSQL.ExecuteSql(strSql);

                    this.lbl_browercount = dt.Rows[0]["BrowerCount"].ToString().Trim() + "次";
                    this.lbl_Content.Text = dt.Rows[0]["ActivityContent"].ToString().Trim();
                    lbl_Description = dt.Rows[0]["ActivityDescription"].ToString().Trim();
                    this.lbl_Time.Text = "发表日期：" + dt.Rows[0]["createtime"].ToString().Trim() + "    文章来源：" + dt.Rows[0]["Source"].ToString().Trim();
                    this.lbl_Title.Text = dt.Rows[0]["ActivityName"].ToString().Trim();

                    //上下页
                    string prevSql = "select top 1 AcitivityNum,ActivityName from [Activity] where SubCategoryType='2' and AcitivityNum<" + id + " order by AcitivityNum desc";
                    DataTable dt_prev = DbHelperSQL.Query(prevSql).Tables[0];
                    if (dt_prev.Rows.Count != 0 && dt_prev != null)
                    {
                        prev = dt_prev.Rows[0]["AcitivityNum"].ToString();
                        lbl_prev = dt_prev.Rows[0]["ActivityName"].ToString();
                    }
                    else
                    {
                        prev = id;
                        lbl_prev = "没有了";
                    }
                    string nextSql = "select top 1 AcitivityNum,ActivityName from [Activity] where SubCategoryType='2' and AcitivityNum>" + id + " order by AcitivityNum asc";
                    DataTable dt_next = DbHelperSQL.Query(nextSql).Tables[0];
                    if (dt_next.Rows.Count != 0 && dt_next != null)
                    {
                        next = dt_next.Rows[0]["AcitivityNum"].ToString();
                        lbl_next = dt_next.Rows[0]["ActivityName"].ToString();
                    }
                    else
                    {
                        next = id;
                        lbl_next = "没有了";
                    }
                }
            }
        }
    }
}
